import time

from A3mall.Page.Page import Page
from selenium.webdriver.common.by import By
class Page1(Page):
    # 点击首页
    home_loc = (By.XPATH, '//*[@id="searchForm"]/div[1]/input')
    # 点击输入框输入：音乐耳机
    sreach_loc = (By.CLASS_NAME, 'search-input')
    sreachbtn_loc=(By.CLASS_NAME,'search-input-btn')
    # 点击商品详情
    shop_loc = (By.XPATH, '/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img')
    # 点击立即购买
    buy_loc = (By.XPATH, '//a[@id="buy-cart" or @class="shop-btn"]')
    # 点击下一步
    next_loc = (By.ID, 'order-button')

    def home(self):
        self.click(self.home_loc)

    def sreach(self):
        self.send_keys(self.sreach_loc,'音乐耳机')

    def sreachbtn(self):
        self.click(self.sreachbtn_loc)

    def shop(self):
        self.click(self.shop_loc)

    def buy(self):
        self.click(self.buy_loc)

    def next(self):
        self.click(self.next_loc)

    def a3mall_luoji2(self):
        self.a3mall_luoji1_login()
        self.home()
        self.sreach()
        self.sreachbtn()
        time.sleep(2)
        self.shop()
        self.buy()
        self.next()
        time.sleep(5)